package com.jingdianjichi.subject.common.enums;

import lombok.Getter;

@Getter
public enum ResultCodeEnum {
    SUCCESS(200, "成功"),
    FAIL(500, "失败"),
    NOT_FOUND(404, "未找到"),
    UNAUTHORIZED(401, "未授权"),
    FORBIDDEN(403, "禁止访问"),
    NOT_SUPPORTED(405, "不支持"),
    PARAM_ERROR(400, "参数错误"),
    NOT_LOGIN(401, "未登录"),
    NOT_EXIST(404, "不存在"),
    NOT_AUTHORIZED(403, "未授权"),
    ;

    private Integer code;
    private String desc;

    ResultCodeEnum(Integer code, String desc){
        this.code = code;
        this.desc = desc;
    }

    public  static ResultCodeEnum getByCode(Integer code){
        for (ResultCodeEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }
}
